{%  load mytag %}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title> template</title>
</head>
<body>

<form action="" method="post" id="form">
  {% csrf_token  %}

  用户名：<input type="text" name="username" /><br/>
  密码<input type="text" name="password"/> <br/>
  <input type="submit" name="提 交"/>

</bar>
</form>
</body>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script >

  $('#button').click(
    function(){
      username = $("[name='username']").val();
      password = $("[name='username']").val();
      csrf = $("[type='hidden']").val();
      data = {'username': username, 'password': password, 'csrf': csrf, };
      // $.post('/register', data)
      $.post('register', $("form").serialize(), function (res){ console.log(res)})
    }
  );
</script>
</html>
